//t线程等main线程
public class Demo17 {
    public static int sum=0;
    public static void main(String[] args) {
        Thread mainThread=new Thread(); //创建main线程的实例
        Thread t=new Thread(()->{
            try {
                mainThread.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("数据和为："+sum);
        });
        t.start();
        for (int i = 1; i <=100 ; i++) {
            sum+=i;
        }
    }
}
